package com.fs.common.pojo;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fs.common.annotation.ColumnDesc;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * @author ACE
 * @desc 用户实体类
 * @creationTime 2019-02-28 14:32
 * @projectName weixinframe
 * @packageName com.fs.pojo
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("s_user")
@EqualsAndHashCode(callSuper=false)
public class User extends IdEntity {
    public static final String SYS_ADM = "sysAdm";

    @ColumnDesc(name = "登录帐号")
    private String account;

    @ColumnDesc(name = "登录密码")
    private String pwd;

    @ColumnDesc(name = "昵称")
    private String nickName;

    @ColumnDesc(name = "手机号码")
    private String mobile;

    @ColumnDesc(name = "企业ID")
    private String comId;

    @ColumnDesc(name = "用户状态")
    private String userStatus = "0";

    @ColumnDesc(name = "推荐码")
    private String decoder;

    @ColumnDesc(name = "被推荐码")
    private String otherDecoder;

    @ColumnDesc(name = "积分")
    private Integer integral = 0;

    @JSONField(format="yyyy-MM-dd HH:mm:ss")
    @ColumnDesc(name = "会员开始日期记录")
    private String startTimeRecord;

    @JSONField(format="yyyy-MM-dd HH:mm:ss")
    @ColumnDesc(name = "会员开始日期")
    private String startTime;

    @JSONField(format="yyyy-MM-dd HH:mm:ss")
    @ColumnDesc(name = "会员结束日期")
    private String endTime;

    @ColumnDesc(name = "累计购买次数")
    private Integer buyCount = 0;

    @ColumnDesc(name = "已使用次数")
    private Integer applyCount = 0;

    @ColumnDesc(name = "部门名称")
    @TableField(exist = false)
    private String companyName;

    @ColumnDesc(name = "角色名称")
    @TableField(exist = false)
    private String roleName;

    @ColumnDesc(name = "剩余检测次数")
    private Integer count = 0;

    @ColumnDesc(name = "套餐ID")
    private String productId;

    /**
     * 0 不需要 1需要
     */
    @ColumnDesc(name = "是否需要修改密码")
    private Integer isUpdatePwd = 0;

    public User(String account, String pwd) {
        this.account = account;
        this.pwd = pwd;
    }

    public User(String account, String pwd,String nickName,String mobile,String comId){
        this.account = account;
        this.pwd = pwd;
        this.nickName = nickName;
        this.mobile = mobile;
        this.comId = comId;
    }

    public boolean isSysAdm(){
        return SYS_ADM.equals(this.account) ? true : false;
    }
}
